import types from './types'
import axios from 'axios'
import Rest from '@/service/rest'

export default {
  /**
   * 获取列表
   */
  getAccountPerms ({commit}, {username}) {
    let url = `/users/user/${username}/perms`
    return new Promise((resolve, reject) => {
      axios.get(url, {
        username: username
      })
      .then(res => {
        let data = res.data
        commit(types.SET_PERMS, data)
        resolve(data)
      })
      .catch(error => {
        Rest.errorHandler(error)
        reject(error)
      })
    })
  }
}
